﻿using System;
using System.Collections.Generic;

namespace Taobao.Tools2.Domain
{
    #region Interface IRepository<T>
    public interface IRepository<T>
    {
        int Add(T model);
        int Update(T model);
        int Delete(T model);
        T Reload(T model);
        void Attach(T model);
        void Detach(T model);

        IEnumerable<T> FindAll();
        IEnumerable<T> Find(System.Linq.Expressions.Expression<Func<T, bool>> predicate);         
        TResult Excute<TResult>(System.Linq.Expressions.Expression<Func<IEnumerable<T>,TResult>> expression);

    }
    #endregion

    #region Interface IRepository<TEntity, in TID>
    public interface IRepository<TEntity, in TID> : IRepository<TEntity>
        where TEntity : IEntity<TID>
        where TID : IEquatable<TID>
    {
        TEntity FindByID(TID id);
        int Delete(TID id);
        int AddOrUpdate(TEntity model);
    }
    #endregion
      
}
